import 'package:safetymonitor/generated/json/base/json_convert_content.dart';
import 'package:safetymonitor/app/core/http/pagination.dart';

Pagination $PaginationFromJson(Map<String, dynamic> json) {
  final Pagination pagination = Pagination();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    pagination.total = total;
  }
  final int? size = jsonConvert.convert<int>(json['size']);
  if (size != null) {
    pagination.size = size;
  }
  final int? current = jsonConvert.convert<int>(json['current']);
  if (current != null) {
    pagination.current = current;
  }
  return pagination;
}

Map<String, dynamic> $PaginationToJson(Pagination entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['size'] = entity.size;
  data['current'] = entity.current;
  return data;
}

extension PaginationExtension on Pagination {
  Pagination copyWith({
    int? total,
    int? size,
    int? current,
  }) {
    return Pagination()
      ..total = total ?? this.total
      ..size = size ?? this.size
      ..current = current ?? this.current;
  }
}